package com.jlcindia.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Lab34 {
	public static void main(String[] args) {
		ApplicationContext ctx=new ClassPathXmlApplicationContext("jlcindia.xml");
		System.out.println("********* Using Target Object **********");
		CustomerService cst=(CustomerService)ctx.getBean("csTarget");
		cst.addCustomer();
		System.out.println("-----------------------\n");
		cst.updateCustomer();
		System.out.println("-----------------------\n");
		AccountService ast=(AccountService)ctx.getBean("asTarget");
		ast.mydeposit();
		System.out.println("-----------------------\n");
		ast.getBal();
		System.out.println("-----------------------\n");
		try{
			ast.withdraw();
		}catch(Exception e){
			System.out.println("Sorry...");
		}
		System.out.println("--------------------------------------------------------------");
		System.out.println("********* Using Proxy Object **********");
		CustomerService csp=(CustomerService)ctx.getBean("csProxy");
		csp.addCustomer();
		System.out.println("-----------------------\n");
		csp.updateCustomer();
		System.out.println("-----------------------\n");
		AccountService asp=(AccountService)ctx.getBean("asProxy");
		asp.mydeposit();
		System.out.println("-----------------------\n");
		asp.getBal();
		System.out.println("-----------------------\n");
		try{
			asp.withdraw();
		}catch(Exception e){
			System.out.println("Sorry...");
		}
		System.out.println("-----------------------");
	}
}
